package cn.tedu.reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class ClassDemo3 {
    public static void main(String[] args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
        //
        Class<String> clz = String.class;

        //查找指定有参构造
        Constructor<String> c = clz.getDeclaredConstructor(
                char[].class, boolean.class);

        //暴力破解，强制进行赋值
        c.setAccessible(true);

        //调用newInstance有参方法并且给有参构造赋值执行有参构造返回实例对象
        String s = c.newInstance(new char[]{'1', '2', '3'}, true);

        //
        System.out.println(s);

    }
}
